<%@page import="dominio.ArticuloItem"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="dominio.*"%>
<%@page import="java.util.*"%>
<%@page import="java.lang.*"%>
<%@page import="java.text.*"%>
<%
	SolicitudArticulo solicitudArticulo = (SolicitudArticulo) request
			.getAttribute("data");
	List<Articulo> articulos = (List<Articulo>) request
			.getAttribute("articulos");
%>
<form id="solicitudArticuloEntrega" method="post" class="form-inline"
	role="form">
	<h1>Solicitud de articulo A Entregar</h1>
	<div class="form-group">
		<label for="tipo" class="col-sm-2 control-label">Codigo
			Solicitud Despacho: </label>
		<div class="col-sm-10">
			<input type="text" class="form-control uneditable-input"
				name="idSolicitud" value="<%=solicitudArticulo.getIdSolicitud()%>">
		</div>
	</div>
	<div class="form-group">
		<label for="nombre" class="col-sm-2 control-label">Despacho
			Id: </label>
		<div class="col-sm-10">
			<input type="text" class="form-control uneditable-input"
				name="idModulo" value="<%=solicitudArticulo.getIdModulo()%>">
		</div>
	</div>
	<div class="form-group">
		<label for="fecha" class="col-sm-2 control-label">Fecha</label>
		<div class="col-sm-10">
			<input type="text" class="form-control uneditable-input"
				name="idFecha" value="<%=solicitudArticulo.getFechaString()%>">
		</div>
	</div>
	<h2>Lista de Articulos Items</h2>

	<div class="table-responsive">
		<table class="table table-bordered table-striped">
			<thead>
				<tr>
					<th>Codigo</th>
					<th>Stock</th>
					<th>Cantidad Solicitada</th>
					<th>Cantidad Entregada</th>
					<th>A Entregar</th>
				</tr>
			</thead>
			<tbody>
				<%
					if (solicitudArticulo != null) {
						List<ArticuloItem> data = solicitudArticulo.getArticulosItems();
						for (Iterator<ArticuloItem> itr = data.iterator(); itr.hasNext();) {
							ArticuloItem articuloItem = itr.next();
							Articulo articulo = null;
							for (Articulo articulovar : articulos) {
								if (articulovar.getCodigo().equals(
										articuloItem.getCodigoArticulo())) {
									articulo = articulovar;
									break;
								}
							}
							int cantidadSujerida = articuloItem.getCantidadSolicitada();
				%>
				<tr>
					<td><span><%=articulo != null ? articulo.getCodigo() : 0%></span></td>
					<td><span><%=articulo != null ? articulo.getCantidad() : 0%></span></td>
					<td><span><%=articuloItem.getCantidadSolicitada()%></span></td>
					<td><span><%=articuloItem.getCantidadEntregada()%></span></td>
					<td><input type="text" name="aEntregar"
						value="<%=cantidadSujerida%>"> <input type="hidden"
						name="codigoArticulo" value="<%=articulo.getCodigo()%>"></td>
				</tr>
				<%}}%>
			</tbody>
		</table>
	</div>
	<div class="form-group">
		<div class="col-sm-2 control-label">
			<div class="col-sm-10">
				<button type="submit" class="btn btn-success">Entregar</button>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript" src="js/tpia.js"></script>